package huachenxing.mimi520.skin
{
	import com.cambright.mixpaint.Block;
	
	import flash.events.MouseEvent;
	
	public class Button extends Block
	{
		private var _color_over:uint;
		public function get color_over():uint
		{
			return _color_over;
		}
		public function set color_over(value:uint):void
		{
			_color_over = value;
		}
		
		private var _color_down:uint;
		public function get color_down():uint
		{
			return _color_down;
		}
		public function set color_down(value:uint):void
		{
			_color_down = value;
		}
		
		override protected function invoke():void
		{
			super.invoke();
			mouseChildren = false;
			addEventListener(MouseEvent.ROLL_OVER, _onOver);
			addEventListener(MouseEvent.ROLL_OUT, _onOut);
			addEventListener(MouseEvent.MOUSE_DOWN, _onDown);
			addEventListener(MouseEvent.MOUSE_UP, _onUp);
		}
		
		override public function dispose():void
		{
			removeEventListener(MouseEvent.ROLL_OVER, _onOver);
			removeEventListener(MouseEvent.ROLL_OUT, _onOut);
			removeEventListener(MouseEvent.MOUSE_DOWN, _onDown);
			removeEventListener(MouseEvent.MOUSE_UP, _onUp);
			super.dispose();
		}
		
		private var _color_up:uint;
		private function _onOver(event:MouseEvent):void
		{
			_color_up = color;
			color = _color_over;
		}
		
		private function _onOut(event:MouseEvent):void
		{
			color = _color_up;
		}
		
		private function _onDown(event:MouseEvent):void
		{
			color = _color_down;
		}
		
		private function _onUp(event:MouseEvent):void
		{
			color = _color_up;
		}
	}
}